<template>
  <div class="hot-tags-box" v-if="list.length">
    <div class="title">热门标签</div>
    <div class="tag-box">
      <div class="tag" v-for="(item, index) of list" :key="index" @click="toDetail(item)">{{item.name}}</div>
    </div>
  </div>
</template>

<script>
import { sideModuleRecommends } from '@/api/api';

export default {
  data() {
    return {
      list: []
    }
  },
  mounted() {
    this.getList();
  },
  methods: {
    async getList() {
      const params = {
        moduleId: 5,
        status: 1
      };
      const res = await sideModuleRecommends(params);
      this.list = res.list || [];
    },
    toDetail(item) {
      const params = {
        keywords: item.name,
        type: 'tag',
        tagId: item.resId
      };
      let routerJump = this.$router.resolve({ name: 'Search', query: params });
      window.open(routerJump.href, '_blank');
    }
  }
}
</script>

<style lang="scss" scoped>
.hot-tags-box {
  margin-bottom: 40px;
  .title {
    font-size: 24px;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    color: #272727;
    line-height: 32px;
    margin-bottom: 24px;
  }
  .tag-box {
    overflow: hidden;
    .tag {
      padding: 7px 16px;
      font-size: 12px;
      
      font-weight: 400;
      color: #696969;
      line-height: 18px;
      background: #FFFFFF;
      border-radius: 4px;
      border: 1px solid #D8D8D8;
      margin-right: 8px;
      margin-bottom: 12px;
      float: left;
      cursor: pointer;
      &:hover {
        border: 1px solid #FF9195;
        color: #F96868;
      }
    }
  }
}
</style>